package com.example.administrator.wallet.adapter;

import android.app.Activity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.TextView;

import com.example.administrator.wallet.R;

import java.util.ArrayList;
import java.util.List;

/**
 * Effect:
 * <p>
 * Author:  CaiYapeng
 * <p>
 * Time  :  2018/8/16.
 */
public class FindAdapter extends BaseAdapter {
    private Activity context;
    private List<String> list_title;
    private List<String> item_one_title;
    private List<String> item_two_title;
    private List<Integer> item_one_icon;
    private List<Integer> item_two_icon;
    private FindListItemAdapter itemOneAdapter;
    private FindListItem2Adapter itemTwoAdapter;


    public FindAdapter(Activity activity, List<String> datas) {
        this.context = activity;
        this.list_title = datas;

        item_one_title=new ArrayList<>();
        item_one_icon=new ArrayList<>();
        item_two_title=new ArrayList<>();
        item_two_icon=new ArrayList<>();
    }

    @Override
    public int getCount() {
        return list_title.size();
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder holder;
        if (view == null) {
            view = View.inflate(context, R.layout.item_find_list, null);
            holder = new ViewHolder();
            view.setTag(holder);
        } else {
            holder = (ViewHolder) view.getTag();
        }

        holder.list_name = (TextView) view.findViewById(R.id.item_title);
        holder.list_item = (GridView) view.findViewById(R.id.iGridView);

        holder.list_name.setText(list_title.get(i));
        if(i==0){
            item_one_icon.clear();
            item_one_title.clear();
            item_one_icon.add(R.drawable.ico_kkyinhang_faxian);
            item_one_icon.add(R.drawable.ico_bibijiaoyi_faxian);
            item_one_icon.add(R.drawable.ico_changwaijiaoyi_faxian);
            item_one_title.add(context.getString(R.string.kkyinhang));
            item_one_title.add(context.getString(R.string.coin_trans));
            item_one_title.add(context.getString(R.string.trade_trans));

            itemOneAdapter = new FindListItemAdapter(context,item_one_icon,item_one_title);
            holder.list_item.setAdapter(itemOneAdapter);
        }else if(i==1){
            item_two_icon.clear();
            item_two_title.clear();
            item_two_icon.add(R.drawable.ico_zhuawawa_faxian);
            item_two_title.add(context.getString(R.string.claw));

            itemTwoAdapter = new FindListItem2Adapter(context,item_two_icon,item_two_title);
            holder.list_item.setAdapter(itemTwoAdapter);
        }

        return view;
    }

    public class ViewHolder {
        TextView list_name;
        GridView list_item;
    }
}
